<form action="{:url()}" method="post" class="form_single">
    <div class="box">
      <div class="box-body">
        <div class="row">
          <div class="col-md-12">
            <div class="form-group">
              <label>消息标题</label>
              <span>（消息的标题）</span>
              <input class="form-control" name="title" placeholder="请输入消息标题" value="{$info['title']}" type="text">
            </div>
          </div>
          
          <div class="col-md-6">
            <div class="form-group">
              <label>接收者类型</label>
              <span>（消息接收者类型）</span>
              <select class="form-control" name="receiver_type" id="receiver_type">
                <option value="all" {if condition="$info.receiver_type eq 'all'"}selected{/if}>全体用户</option>
                <option value="user" {if condition="$info.receiver_type eq 'user'"}selected{/if}>指定用户</option>
                <option value="vip" {if condition="$info.receiver_type eq 'vip'"}selected{/if}>VIP用户</option>
              </select>
            </div>
          </div>

          <div class="col-md-6" id="receiver_user" style="display: none;">
            <div class="form-group">
              <label>指定用户</label>
              <span>（选择接收消息的用户）</span>
              <select class="form-control" name="receiver_id">
                <option value="">请选择用户</option>
                {volist name="users" id="user"}
                <option value="{$user.id}" {if condition="$info.receiver_id eq $user.id"}selected{/if}>{$user.nickname}</option>
                {/volist}
              </select>
            </div>
          </div>

          <div class="col-md-6">
            <div class="form-group">
              <label>消息类型</label>
              <span>（消息的类型）</span>
              <select class="form-control" name="type">
                <option value="system" {if condition="$info.type eq 'system'"}selected{/if}>系统消息</option>
                <option value="notice" {if condition="$info.type eq 'notice'"}selected{/if}>通知消息</option>
                <option value="promotion" {if condition="$info.type eq 'promotion'"}selected{/if}>推广消息</option>
              </select>
            </div>
          </div>

          <div class="col-md-6">
            <div class="form-group">
              <label>发送时间</label>
              <span>（消息发送时间，留空立即发送）</span>
              <input class="form-control" name="send_time" placeholder="请选择发送时间" value="{$info['send_time']}" type="datetime-local">
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>消息内容</label>
              <span>（消息的详细内容）</span>
              <textarea class="form-control" name="content" rows="6" placeholder="请输入消息内容">{$info['content']}</textarea>
            </div>
          </div>

          <div class="col-md-12">
            <div class="form-group">
              <label>备注</label>
              <span>（消息的备注说明）</span>
              <textarea class="form-control" name="remark" rows="3" placeholder="请输入备注">{$info['remark']}</textarea>
            </div>
          </div>
            
        </div>
      </div>
      <div class="box-footer">
        
        <input type="hidden" name="id" value="{$info['id']|default='0'}"/>
          
        {include file="layout/edit_btn_group"/}
        
      </div>
    </div>
</form>

<script>
$(document).ready(function() {
    // 根据接收者类型显示/隐藏指定用户选择
    function toggleReceiverUser() {
        var receiverType = $('#receiver_type').val();
        if (receiverType === 'user') {
            $('#receiver_user').show();
        } else {
            $('#receiver_user').hide();
        }
    }
    
    // 初始化显示状态
    toggleReceiverUser();
    
    // 监听接收者类型变化
    $('#receiver_type').change(function() {
        toggleReceiverUser();
    });
});
</script>